<template>
  <div class="app-container">
    <div style="margin-bottom: 55px;">
      <el-row>
        <el-card shadow="never">
          <el-row style="display: flex; align-items: center;">
            <el-col :span="2">
              <el-button style="fpadding: 3px 0" type="text" icon="el-icon-arrow-left" size="small" @click="back">返回</el-button>
            </el-col>
            <el-col :span="18">
              <el-tag type="primary" effect="dark" style="margin-right: 20px">非业务结算单</el-tag>
              <strong>ERP发票号：{{detailForm.orderNo}}</strong>
              <el-divider direction="vertical"></el-divider>
              <span>发票日期：{{detailForm.settleTime}}</span>
              <el-divider direction="vertical"></el-divider>
              <span>单据状态: </span>
              <el-link type="success" :underline="false">{{detailForm.settlebillStatusName}}</el-link>
              <el-divider direction="vertical"></el-divider>
            </el-col>
            <el-col :span="6">
<!--              <el-button type="primary" style="float: right;margin-left: 10px" size="small" @click="submitForm"  v-if="detailForm.settlebillStatus == 0">保存</el-button>-->
            </el-col>
          </el-row>
        </el-card>
      </el-row>
      <el-row style="padding-top: 10px" class="v-deep">
        <el-col :span="24" :xs="24">
          <el-collapse v-model="activeNames2">
            <el-collapse-item name="1">
              <template slot="title">
                <div>主体信息</div>
              </template>
              <div style="padding: 5px">
                <el-form ref="detailForm" :model="detailForm" :rules="rules" label-position="top" label-width="80px" size="small">
                  <el-row :gutter="10">
                    <el-col :span="6">
                      <el-form-item label="形式发票类型">
                        <strong>{{detailForm.natureTypeName}}</strong>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="发票类型" prop="invoiceType">
                        <el-select v-model="detailForm.invoiceType">
                          <el-option
                            v-for="dict in dict.type.invoice_type"
                            :key="dict.value"
                            :label="dict.label"
                            :value="dict.value"
                          ></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="应用于发票号"  prop="sourceOrderNo">
                        <el-input v-model="detailForm.sourceOrderNo"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="开票人" prop="invoiceName">
                        <el-input v-model="detailForm.invoiceName"></el-input>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="10">
                    <el-col :span="6">
                      <el-form-item label="账单条款" prop="termsCode">
                        <el-select v-model="detailForm.termsCode">
                          <el-option
                            v-for="dict in dict.type.terms_code"
                            :key="dict.value"
                            :label="dict.label"
                            :value="dict.value"
                          ></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="币别" prop="currencyCode">
                        <el-select v-model="detailForm.currencyCode">
                          <el-option
                            v-for="dict in dict.type.currency_code"
                            :key="dict.value"
                            :label="dict.label"
                            :value="dict.value"
                          ></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="汇率" prop="exchRate">
                        <el-input v-model="detailForm.exchRate"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="来源" >
                        {{detailForm.postFromCoName}}
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="10">
                    <el-col :span="6">
                      <el-form-item label="购方名称" prop="buyerName">
                        <el-input v-model="detailForm.buyerName"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="购方纳税识别号" prop="buyerNumber">
                        <el-input v-model="detailForm.buyerNumber"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="购方地址" prop="buyerAddress">
                        <el-input v-model="detailForm.buyerAddress"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="购方电话" prop="buyerTel">
                        <el-input v-model="detailForm.buyerTel"></el-input>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="10">
                    <el-col :span="6">
                      <el-form-item label="购方开户行" prop="buyerBank">
                        <el-input v-model="detailForm.buyerBank"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="购方账号" prop="buyerAccount">
                        <el-input v-model="detailForm.buyerAccount"></el-input>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="10">
                    <el-col :span="6">
                      <el-form-item label="销方名称" prop="sellerName">
                        <el-input v-model="detailForm.sellerName"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="销方纳税识别号" prop="sellerNumber">
                        <el-input v-model="detailForm.sellerNumber"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="销方地址" prop="sellerAddress">
                        <el-input v-model="detailForm.sellerAddress"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="销方电话" prop="sellerTel">
                        <el-input v-model="detailForm.sellerTel"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="销方开户行" prop="sellerBank">
                        <el-input v-model="detailForm.sellerBank"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="销方账号" prop="sellerAccount">
                        <el-input v-model="detailForm.sellerAccount"></el-input>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="10">

                    <el-col :span="6">
                      <el-form-item label="收款人" prop="collectName">
                        <el-input v-model="detailForm.collectName"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="收票人邮箱" prop="collectMail">
                        <el-input v-model="detailForm.collectMail"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="收票人手机号" prop="collectMobile">
                        <el-input v-model="detailForm.collectMobile"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="税日期" prop="taxDate">
                        <el-date-picker clearable
                                        style="width: 100%;"
                                        v-model="detailForm.taxDate"
                                        type="date"
                                        value-format="yyyy-MM-dd"
                                        placeholder="请选择税日期">
                        </el-date-picker>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="10">
                    <el-col :span="6">
                      <el-form-item label="到期日期" prop="dueDate">
                        <el-date-picker clearable
                                        style="width: 100%;"
                                        v-model="detailForm.dueDate"
                                        type="date"
                                        value-format="yyyy-MM-dd"
                                        placeholder="请选择到期日期">
                        </el-date-picker>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="发货日期" prop="deliveryTime">
                        <el-date-picker clearable
                                        style="width: 100%;"
                                        v-model="detailForm.deliveryTime"
                                        type="date"
                                        value-format="yyyy-MM-dd"
                                        placeholder="请选择发货日期">
                        </el-date-picker>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="结算日期" prop="settleTime">
                        <el-date-picker clearable
                                        style="width: 100%;"
                                        v-model="detailForm.settleTime"
                                        type="date"
                                        value-format="yyyy-MM-dd"
                                        placeholder="请选择结算日期">
                        </el-date-picker>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="金额" prop="collectName">
                        <el-input v-model="detailForm.amount"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="运费" prop="collectName">
                        <el-input v-model="detailForm.freightFee"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="杂费" prop="collectName">
                        <el-input v-model="detailForm.miscChargesFee"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="税额">
                        <el-input v-model="tax" readonly></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="金额(不含税)">
                        <el-input v-model="feeWithoutTax" readonly></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="金额(含税)">
                        <el-input v-model="fee" readonly></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="18">
                      <el-form-item label="备注" prop="remark">
                        <el-input v-model="detailForm.remark"></el-input>
                      </el-form-item>
                    </el-col>
                  </el-row>
                </el-form>
              </div>
            </el-collapse-item>
          </el-collapse>
        </el-col>
      </el-row>
      <el-row style="padding-top: 10px" class="v-deep">
        <el-col :span="24" :xs="24">
          <el-collapse v-model="activeNames">
            <el-collapse-item name="1" >
              <template slot="title">
                <div>商品信息</div>
              </template>
              <div style="padding: 5px" class="low-height-th-table">
                <el-table
                  border
                  stripe
                  default-expand-all
                  ref="tableRef"
                  v-loading="loading"
                  :data="settlebillEntryList"
                  :header-cell-style= "{
                    'font-size': '12px !important',
                    'font-weight': '500 !important',
                    'color':'#FFF',
                    'padding': '0px 0',
                    'background-color':'rgb(51 112 255 / 80%)',
                    textAlign: 'left',
                    'height': '25px !important'
                  }"
                  :cell-style="{ padding: '8px 10px 8px 0', textAlign: 'left', 'height': '25px !important' }"
                  highlight-current-row style="width: 100%;"
                  height="320px"
                >
                  <el-table-column label="序号" align="center" prop="index" width="50">
                    <template slot-scope="scope">{{scope.$index+1}}</template>
                  </el-table-column>
                  <el-table-column label="产品名称" align="left" prop="productCode" width="250">
                    <template slot-scope="scope">
                      <el-input size="mini" v-model="scope.row.productName" maxlength = 0 clearable placeholder="请选择"  readonly>
                        <el-button slot="append" icon="el-icon-search" style="padding: 0 10px;" @click="openSearchProductDialogOpen(scope.$index)">
                        </el-button>
                      </el-input>
                    </template>
                  </el-table-column>
                  <el-table-column label="税编简称" align="left" prop="taxShortName" width="180">
                    <template slot-scope="scope">
                      <el-input size="mini" v-model="scope.row.taxShortName" maxlength = 0 clearable placeholder="请选择" readonly>
                        <el-button slot="append" icon="el-icon-search" style="padding: 0 10px;" @click="openSearchTaxCategoryDialogOpen(scope.$index)">
                        </el-button>
                      </el-input>
                    </template>
                  </el-table-column>
                  <el-table-column label="税编" align="left" prop="taxCategoryCode" width="200">
                    <template slot-scope="scope">
                      {{scope.row.taxCategoryCode}}
                    </template>
                  </el-table-column>
                  <el-table-column label="规格型号" align="left" prop="specificatCode" width="150">
                    <template slot-scope="scope">
                      <el-input size="mini" v-model="scope.row.specificatCode" clearable placeholder="请输入" >
                      </el-input>
                    </template>
                  </el-table-column>
                  <el-table-column label="单位" align="left" prop="unit" width="120">
                    <template slot-scope="scope">
                      <el-input size="mini" v-model="scope.row.unit" clearable placeholder="请输入" >
                      </el-input>
                    </template>
                  </el-table-column>
                  <el-table-column label="数量" align="left" prop="qty" width="190">
                    <template slot-scope="scope">
                      <el-input-number size="mini" v-model="scope.row.qty" controls-position="right" :min="0" :max="9999999" @change="changeQty(scope.$index,scope.row)" style="width: 150px;"></el-input-number>
                    </template>
                  </el-table-column>
                  <el-table-column label="单价(不含税)" align="left" prop="withoutPrice"  width="190" >
                    <template slot-scope="scope">
                      <el-input-number  size="mini" v-model="scope.row.withoutPrice" :precision="8" @change="changeWithoutPrice(scope.$index,scope.row)"controls-position="right" :min="0.01" :max="9999999" style="width: 150px;"></el-input-number>
                    </template>
                  </el-table-column>
                  <el-table-column label="金额(不含税)" align="left" prop="withoutAmount" width="140"  >
                      <template slot-scope="scope">
                        <el-input-number  size="mini" v-model="scope.row.withoutAmount" :precision="8" @change="changeWithoutAmount(scope.$index,scope.row)"controls-position="right" :min="0.01" :max="9999999" style="width: 150px;"></el-input-number>
                      </template>
                  </el-table-column>
                  <el-table-column label="单价(含税)" align="left" prop="price" width="190" >
                    <template slot-scope="scope">
                      <el-input-number size="mini" v-model="scope.row.price" :precision="8"  @change="changePrice(scope.$index,scope.row)" controls-position="right" :min="0.01" :max="9999999" style="width: 150px;"></el-input-number>
                    </template>
                  </el-table-column>
                  <el-table-column label="金额(含税)" align="left" prop="amount" width="140">
                      <template slot-scope="scope">
                        <el-input-number  size="mini" v-model="scope.row.amount" :precision="8" @change="changeAmount(scope.$index,scope.row)"controls-position="right" :min="0.01" :max="9999999" style="width: 150px;"></el-input-number>
                      </template>
                  </el-table-column>
                  <el-table-column label="税率" align="left" prop="taxRate"  width="80">
                    <template slot-scope="scope">
                      {{scope.row.taxRate}}%
                    </template>
                  </el-table-column>
                  <el-table-column label="税额" align="left" prop="tax"  width="150">
                    <template slot-scope="scope">
                      {{scope.row.tax | formatCurrency}}
                    </template>
                  </el-table-column>
                  <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="120" >
                    <template slot-scope="scope">
                      <el-button
                        type="text"
                        size="mini"
                        @click="deleteEntry(scope.$index)"
                        style="color: red"
                        v-if="scope.$index > 0"
                      >移除</el-button>
                      <el-divider direction="vertical" v-if="scope.$index > 0"></el-divider>
                      <el-button
                        type="text"
                        size="mini"
                        @click="addEntry()"
                      >新增</el-button>
                    </template>
                  </el-table-column>
                  <div slot="empty">
                    <svg-icon icon-class="search-none" style="font-size: 64px;" />
                    <p>暂无数据</p>
                  </div>
                </el-table>
              </div>
            </el-collapse-item>
          </el-collapse>
        </el-col>
      </el-row>
    </div>
    <div style="position: fixed;z-index: 999;bottom: 0px;width: 100%;margin-top: 16px;box-shadow: rgba(0, 0, 0, 0.15) 0px 2px 12px 4px;">
      <div style="display: flex;height: 56px;background-color: #FFFF;">
        <div style="width: 100px;padding: 15px 28px;background-color: #3370ff;color: #FFF;font-size: 20px;font-weight: 600;">
          <span>合计</span>
        </div>
        <div style="display: flex;flex-grow: 1;align-items: center;">
          <div style="width: 350px;padding: 0 15px;">
            <svg-icon icon-class="without-tax2" style="color: rgb(255, 88, 88);    font-size: 18px;"/> 金额(不含税)
            <span style="font-weight: 800; margin-left: 5px">
              ¥{{detailForm.feeWithoutTax | formatCurrency}}
            </span>

          </div>
          <div style="width: 350px;padding: 0 15px;">
            <svg-icon icon-class="with-tax2" style="color: rgb(255, 165, 71);    font-size: 18px;"/>  金额(含税)
            <span style="font-weight: 800; margin-left: 5px">
              ¥{{detailForm.fee | formatCurrency}}
            </span>

          </div>
          <div style="width: 300px;padding: 0 15px;">
            <svg-icon icon-class="tax"style="color: rgb(41, 180, 240);    font-size: 18px;" />  税额
            <span style="font-weight: 800; margin-left: 5px">
              ¥{{detailForm.tax | formatCurrency}}
            </span>
          </div>

          <div style="width: 300px;padding: 0 15px;">
            <el-button type="primary" style="float: right;margin-left: 10px" @click="submitForm" >保 存</el-button>
          </div>
        </div>
      </div>
    </div>

    <!-- 查看发票 -->
    <el-dialog v-dialogDrag  :close-on-click-modal="false" title="查看发票" :visible.sync="invoiceOpen" width="1400px" append-to-body>
      <div class="dialog_box" style="height:650px;">
        <el-row>
            <el-col :span="10">
              <div style="height:575px; overflow-y: auto">
                <el-tabs type="border-card">
                <el-tab-pane label="发票信息">
                  <el-descriptions class="margin-top" title="基本信息" :column="2" size="mini" border>
                    <template slot="title">
                      <div>基本信息 <span class="invoice-type">{{detailForm.invoiceTypeName}}</span></div>
                    </template>
                    <el-descriptions-item>
                      <template slot="label">
                        发票代码：
                      </template>
                      {{detailForm.invoiceCode}}
                    </el-descriptions-item>
                    <el-descriptions-item>
                      <template slot="label">
                        发票号码：
                      </template>
                      {{detailForm.invoiceNo}}
                    </el-descriptions-item>
                    <el-descriptions-item>
                      <template slot="label">
                        开票日期：
                      </template>
                      {{detailForm.invoiceDate}}
                    </el-descriptions-item>
                    <el-descriptions-item>
                      <template slot="label">
                        金额(不含税):
                      </template>
                      ¥{{detailForm.feeWithoutTax | formatCurrency}}
                    </el-descriptions-item>
                    <el-descriptions-item>
                      <template slot="label">
                        税额:
                      </template>
                      ¥{{detailForm.tax | formatCurrency}}
                    </el-descriptions-item>
                    <el-descriptions-item>
                      <template slot="label">
                        金额(含税):
                      </template>
                      ¥{{detailForm.fee | formatCurrency}}
                    </el-descriptions-item>
                    <el-descriptions-item>
                      <template slot="label">
                        校验码:
                      </template>
                      {{detailForm.checkCode}}
                    </el-descriptions-item>
                  </el-descriptions>

                  <el-descriptions class="margin-top" title="抬头信息" :column="1" size="mini" border>
                    <template slot="extra">
                      <el-radio-group v-model="isWithout" size="mini">
                        <el-radio-button label="销方"></el-radio-button>
                        <el-radio-button label="购方"></el-radio-button>
                      </el-radio-group>
                    </template>
                    <el-descriptions-item>
                      <template slot="label">
                        名称:
                      </template>
                      {{detailForm.name}}
                    </el-descriptions-item>
                    <el-descriptions-item>
                      <template slot="label">
                        纳税识别号:
                      </template>
                      {{detailForm.buyerNumber}}
                    </el-descriptions-item>
                    <el-descriptions-item>
                      <template slot="label">
                        地址、电话:
                      </template>
                      {{detailForm.buyerAddress}}-{{detailForm.buyerTel}}
                    </el-descriptions-item>
                    <el-descriptions-item>
                      <template slot="label">
                        开户行及账号:
                      </template>
                      {{detailForm.buyerBank}}-{{detailForm.buyerAccount}}
                    </el-descriptions-item>
                  </el-descriptions>

                <el-descriptions class="margin-top" title="业务信息" :column="2" size="mini" border>

                  <el-descriptions-item>
                    <template slot="label">
                      <i class="el-icon-user"></i>
                      发货日期:
                    </template>
                  </el-descriptions-item>
                  <el-descriptions-item>
                    <template slot="label">
                      特殊开票:
                    </template>
                  </el-descriptions-item>
                  <el-descriptions-item>
                    <template slot="label">
                      开票网点:
                    </template>
                  </el-descriptions-item>
                  <el-descriptions-item>
                    <template slot="label">
                      站点:
                    </template>
                  </el-descriptions-item>
                </el-descriptions>
                <el-descriptions class="margin-top" title="商品明细" :column="1" size="mini" border >
                    <template slot="extra">
                      <el-radio-group v-model="isWithout" size="mini">
                        <el-radio-button label="含税"></el-radio-button>
                        <el-radio-button label="不含税"></el-radio-button>
                      </el-radio-group>
                    </template>
                    <el-descriptions-item>
                      <el-table
                        border
                        stripe
                        default-expand-all
                        ref="invoiceDetailEntry"
                        v-loading="loading"
                        :data="settlebillEntryList"
                        :header-cell-style= "{
                          'font-size': '12px !important',
                          'font-weight': '500 !important',
                          'color':'#FFF',
                          'padding': '0px 0',
                          'background-color':'rgb(51 112 255 / 80%)',
                          textAlign: 'left',
                          'height': '30px !important'
                        }"
                        :cell-style="{ padding: '8px 10px 8px 0', textAlign: 'left' }"
                        highlight-current-row
                        style="width: 555px;margin-left: -32px;margin-top: -10px;"
                        height="300px"
                      >
                        <el-table-column type="selection" width="55" align="center" />
                        <el-table-column label="序号" align="center" prop="index" width="50">
                          <template slot-scope="scope">{{scope.$index+1}}</template>
                        </el-table-column>
                        <el-table-column label="产品名称" align="left" prop="productName" width="250">
                        </el-table-column>
                        <el-table-column label="税编简称" align="left" prop="taxShortName" width="180">
                        </el-table-column>
                        <el-table-column label="规格型号" align="left" prop="specificatCode" width="150">
                        </el-table-column>
                        <el-table-column label="单位" align="left" prop="unit" width="120">
                        </el-table-column>
                        <el-table-column label="数量" align="left" prop="qty" width="140">
                        </el-table-column>
                        <el-table-column label="单价(不含税)" align="left" prop="withoutPrice"  width="160" >
                        </el-table-column>
                        <el-table-column label="金额(不含税)" align="left" prop="withoutAmount" width="140"  >
                        </el-table-column>
                        <el-table-column label="单价(含税)" align="left" prop="price" width="160" >
                        </el-table-column>
                        <el-table-column label="金额(含税)" align="left" prop="amount" width="140">
                        </el-table-column>
                        <el-table-column label="折扣金额(不含税)" align="left" prop="withoutDiscountAmount" width="160"  >
                        </el-table-column>
                        <el-table-column label="折扣金额(含税)" align="left" prop="discountAmount" width="160">
                        </el-table-column>
                        <el-table-column label="税率" align="left" prop="taxRate"  width="80">
                        </el-table-column>
                        <el-table-column label="税额" align="left" prop="tax"  width="120">
                        </el-table-column>
                        <div slot="empty">
                          <svg-icon icon-class="search-none" style="font-size: 64px;" />
                          <p>暂无数据</p>
                        </div>
                      </el-table>
                    </el-descriptions-item>

                  </el-descriptions>


                </el-tab-pane>
              </el-tabs>
              </div>
            </el-col>
        </el-row>
      </div>
    </el-dialog>

    <!-- 产品查询-弹出查询 -->
    <el-dialog v-dialogDrag  :close-on-click-modal="false" title="产品查询" :visible.sync="searchProductCodeDialogOpen" width="800px" append-to-body>
      <div class="dialog_box" style="height:550px;">
        <el-form label-position="left" :model="searchProductCodeQueryParams" :inline="true"  ref="searchProductCodeQueryForm" label-width="88px" >
          <el-form-item  prop="searchProductCodeSearchValue">
            <el-input
              v-model="searchProductCodeQueryParams.searchValue"
              size="mini"
              placeholder="请输入编码或名称查询产品"
              @keyup.enter.native="handleSearchProductCodeQuery"
              clearable
            />
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleSearchProductCodeQuery">查询</el-button>
          </el-form-item>
        </el-form>
        <el-table v-loading="searchProductCodeSelectLoading" :data="searchProductCodeList"
                  height="400"
                  @row-click="handleSearchProductCodeRowClick"
                  ref="searchProductCodeSingleTable"
                  :row-key="getSearchProductCodeListRowKey"
                  :row-style="{height:2+'px'}"
                  :header-cell-style= "{
                        'font-size': '14px !important',
                        'font-weight': '500 !important',
                        'background-color':'rgb(241 241 241 / 52%)'
                      }"
                  :cell-style="{padding:'2px 4px'}"
                  border
                  @selection-change="handleSearchProductCodeSelectionChange">
          <el-table-column type="selection" width="55" align="center"/>
          <!-- 数据 -->
          <el-table-column prop="productCode" label="货物及服务编码" width="200"></el-table-column>
          <el-table-column prop="productName" label="货物及服务名称" ></el-table-column>
          <el-table-column prop="isTaxName" label="含税" width="100"></el-table-column>
          <el-table-column prop="taxRateName" label="税率" width="80"></el-table-column>
          <el-table-column prop="price" label="单价" width="140">
            <template slot-scope="scope">
              <span v-if="scope.row.price && scope.row.price != 'NULL' "> {{scope.row.price | formatCurrency}} </span>
              <span v-else> - </span>
            </template>
          </el-table-column>
<!--          <el-table-column prop="remark" label="备注" width="120">-->

<!--          </el-table-column>-->
        </el-table>
        <pagination
          v-show="searchProductCodeTotal>0"
          :total="searchProductCodeTotal"
          :page.sync="searchProductCodeQueryParams.pageNum"
          :limit.sync="searchProductCodeQueryParams.pageSize"
          @pagination="getSearchProductCodeList"
        />
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button size="mini" type="primary" @click="confirmSearchProductCode">确 定</el-button>
        <el-button size="mini"   @click="searchProductCodeCancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 税收分类查询-弹出查询 -->
    <el-dialog v-dialogDrag  :close-on-click-modal="false" title="税收分类查询" :visible.sync="searchTaxCategoryCodeDialogOpen" width="1000px" append-to-body>
      <div class="dialog_box" style="height:550px;">
        <el-form label-position="left" :model="searchTaxCategoryCodeQueryParams" :inline="true"  ref="searchTaxCategoryCodeQueryForm" label-width="88px" >
          <el-form-item  prop="searchTaxCategoryCodeSearchValue">
            <el-input
              v-model="searchTaxCategoryCodeQueryParams.searchValue"
              size="mini"
              placeholder="请输入编码或名称查询税收分类"
              @keyup.enter.native="handleSearchTaxCategoryCodeQuery"
              clearable
            />
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleSearchTaxCategoryCodeQuery">查询</el-button>
          </el-form-item>
        </el-form>
        <el-table v-loading="searchTaxCategoryCodeSelectLoading" :data="searchTaxCategoryCodeList"
                  height="400"
                  @row-click="handleSearchTaxCategoryCodeRowClick"
                  ref="searchTaxCategoryCodeSingleTable"
                  :row-key="getSearchTaxCategoryCodeListRowKey"
                  :row-style="{height:2+'px'}"
                  :header-cell-style= "{
                        'font-size': '14px !important',
                        'font-weight': '500 !important',
                        'background-color':'rgb(241 241 241 / 52%)'
                      }"
                  :cell-style="{padding:'2px 4px'}"
                  border
                  @selection-change="handleSearchTaxCategoryCodeSelectionChange">
          <el-table-column type="selection" width="55" align="center"/>
          <!-- 数据 -->
          <el-table-column prop="taxShortName" label="税收分类简称" width="160"></el-table-column>
          <el-table-column prop="taxCategoryCode" label="税收分类编码" width="200"></el-table-column>
          <el-table-column prop="taxRateName" label="税率" width="80"></el-table-column>
          <el-table-column prop="policyName" label="优惠政策"></el-table-column>
        </el-table>
        <pagination
          v-show="searchProductCodeTotal>0"
          :total="searchProductCodeTotal"
          :page.sync="searchProductCodeQueryParams.pageNum"
          :limit.sync="searchProductCodeQueryParams.pageSize"
          @pagination="getSearchTaxCategoryCodeList"
        />
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button size="mini" type="primary" @click="confirmSearchTaxCategoryCode">确 定</el-button>
        <el-button size="mini"   @click="searchTaxCategoryCodeCancel">取 消</el-button>
      </div>
    </el-dialog>


  </div>

</template>
<style lang="scss">
  .input_num .el-input__inner{
    padding: 0 0 0 15px !important;
    color: red;
    font-weight: 700;
  }
  .el-table .warning-row {
    background: oldlace;
  }
  .el-table .success-row {
    background: #f0f9eb;
  }
  .el-card__body, .el-main {
    padding: 5px 20px !important;
  }

  .collapse-title{
    background-color: red;
  }
  .el-collapse-item__header.is-active {
    border-bottom: 1px solid #f0f2f5 !important;
  }
  .el-collapse-item__header::before{
    content: "";
    display: block;
    width: 3px;
    height: 20px;
    position: absolute;
    background-color: #297cf0;
    left: 0px;
    top: 35px;
    -ms-transform: translateY(-50%);
    transform: translateY(-50%);
  }

  .el-collapse-item__header div{
    margin-left: 10px;
  }
  .el-form-item__label{
    margin-bottom: -12px;
  }

  .v-deep{
    .el-collapse-item__arrow {
      width: 40px;
    }
    .el-icon-arrow-right:before {
      content: "展开";
      font-size: 14px;
      font-family: 'heiti';
      color: #2295ff;
    }
    .el-collapse-item__arrow.is-active {
      transform: none;
    }
    .el-collapse-item__arrow.is-active::before {
      content: "收起";
      font-size: 14px;
      font-family: 'heiti';
      color: #2295ff;
    }
    .el-form-item--mini.el-form-item, .el-form-item--small.el-form-item {
      margin-bottom: 8px;
    }
  }

  .el-descriptions__header{
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: justify;
    -ms-flex-pack: justify;
    justify-content: space-between;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    margin-bottom: 5px !important;
    margin-top: 5px;
  }
  .el-descriptions__title::before{
    content: "";
    display: block;
    width: 3px;
    height: 20px;
    position: absolute;
    background-color: #297cf0;
    left: 0px;
    margin-top: 11px;
    -ms-transform: translateY(-50%);
    transform: translateY(-50%);
  }
  .invoice-type {
    font-size: 12px;
    font-weight: 500;
    border: 2px solid;
    padding: 2px 6px;
    color: hsl(158deg 86% 34%);
    border-radius: 4px;
  }
  .invoice-type::before,
  .invoice-type::after {
    position: absolute;
    content: '';
    width: 6px;
    height: 6px;
    background-color: #fff;
    border: 2px solid hsl(158deg 86% 34%);
    border-left-color: transparent;
    border-bottom-color: transparent;
    border-radius: 50%;
    margin-top: 10px;
  }

  .invoice-type::before {
    margin-left: -10px;
    transform: rotate(45deg);
  }

  .invoice-type::after {
    margin-left: 3px;
    transform: rotate(-135deg);
  }

</style>

<script>
import { listSettlebill, getSettlebill, delSettlebill, addSettlebill, updateSettlebill } from "@/api/doc/settlebill";
import { listProduct} from "@/api/saleconfig/product";
import { listTaxcategory} from "@/api/saleconfig/taxcategory";

import Viewer from 'v-viewer';
export default {
    name: "SettleBillNoListUpdate",
    dicts: ['invoice_type', 'collection_type', 'business_type', 'tax_rate', 'terms_code', 'currency_code'],
    data() {
        return {
            activeNames: ['1'],
            activeNames2: ['1'],
            detailForm:{},
            // 表单校验
            rules: {
                invoiceType: [
                    { required: true, trigger: "blur", message: "发票类型不能为空" }
                ],
                invoiceName: [
                    { required: true, trigger: "blur", message: "开票人不能为空" }
                ],
                termsCode: [
                    { required: true, trigger: "blur", message: "账单条款不能为空" }
                ],
                currencyCode: [
                    { required: true, trigger: "blur", message: "币别不能为空" }
                ],
                exchRate: [
                    { required: true, trigger: "blur", message: "汇率不能为空" }
                ],
                buyerName: [
                    { required: true, trigger: "blur", message: "购方名称不能为空" }
                ],
                buyerNumber: [
                    { required: true, trigger: "blur", message: "购方纳税识别号不能为空" }
                ],
                buyerAddress: [
                    { required: true, trigger: "blur", message: "购方地址不能为空" }
                ],
                buyerTel: [
                    { required: true, trigger: "blur", message: "购方电话不能为空" }
                ],
                buyerBank: [
                    { required: true, trigger: "blur", message: "购方开户行不能为空" }
                ],
                buyerAccount: [
                    { required: true, trigger: "blur", message: "购方账号不能为空" }
                ],
                sellerName: [
                    { required: true, trigger: "blur", message: "销方名称不能为空" }
                ],
                sellerNumber: [
                    { required: true, trigger: "blur", message: "销方纳税识别号不能为空" }
                ],
                sellerAddress: [
                    { required: true, trigger: "blur", message: "销方地址不能为空" }
                ],
                sellerTel: [
                    { required: true, trigger: "blur", message: "销方电话不能为空" }
                ],
                sellerBank: [
                    { required: true, trigger: "blur", message: "销方开户行不能为空" }
                ],
                sellerAccount: [
                    { required: true, trigger: "blur", message: "销方账号不能为空" }
                ],
                collectMail: [
                    { required: true, message: "收票人邮箱地址不能为空", trigger: "blur" },
                    {
                        type: "email",
                        message: "请输入正确的邮箱地址",
                        trigger: ["blur", "change"]
                    }
                ],
                collectMobile: [
                    {
                        pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
                        message: "请输入正确的手机号码",
                        trigger: "blur"
                    }
                ]
            },
            feeWithoutTax: 0,
            fee: 0,
            tax: 0,
            loading:false,
            settlebillEntryList:[],
            settlebillEntry: {
                id : null,
                entryId : null,
                settleId : null,
                custId : null,
                siteCode : null,
                siteName : null,
                unit : '',
                qty : 0,
                withoutPrice : 0,
                withoutAmount : 0,
                taxRate : 0,
                tax : 0,
                deductAmount : 0,
                deductRate : 0,
                withoutDiscountAmount : 0,
                discountAmount : 0,
                price : 0,
                amount : 0,
                policyCode : null,
                policyName : null,
                freeTaxType : null,
                freeTaxTypeName : null,
                taxShortName : null,
                productCode : '',
                productName : '',
                specificatCode : null,
                createTime: null
            },
            isWithout:'含税',
            invoiceOpen:false,
            options:{
                zIndex: 99999,
                inline: true,
                button: true,
                navbar: true,
                title: true,
                toolbar: true,
                tooltip: true,
                movable: true,
                zoomable: true,
                rotatable: true,
                scalable: true,
                transition: true,
                fullscreen: false,
                keyboard: true,
                url: 'data-source'
            },

            currentRowIdx : 0,
            /* ======================================查询条件-产品选择======================================  */
            searchProduct:{},
            searchProductCodes:[],
            searchProductNames:[],
            searchProductCodeTotal: 0,
            searchProductCodeList: [],
            searchProductCodeDialogOpen: false,
            searchProductCodeSelectLoading: false,
            searchProductCodeQueryParams: {
                searchValue: null,
                pageNum: 1,
                pageSize: 20,
            },

            /* ======================================查询条件-产品选择======================================  */
            searchTaxCategoryCodes:[],
            searchTaxCategoryNames:[],
            searchTaxCategoryCodeTotal: 0,
            searchTaxCategoryCodeList: [],
            searchTaxCategoryCodeDialogOpen: false,
            searchTaxCategoryCodeSelectLoading: false,
            searchTaxCategoryCodeQueryParams: {
                searchValue: null,
                pageNum: 1,
                pageSize: 20,
            },
        };
    },
    created() {
        // 获取发票ID
        let settleId = this.$route.params && this.$route.query.settleId;
        console.log("获取结算单ID：" + settleId);
        this.init(settleId);
    },
    methods: {
        init(settleId){
            this.$modal.loading("正在初始化，请稍候...");
            getSettlebill(settleId).then(response => {
                this.detailForm = response.data;
                this.feeWithoutTax = this.detailForm.feeWithoutTax;
                this.fee = this.detailForm.fee;
                this.tax = this.detailForm.tax;
                this.settlebillEntryList = response.data.tscSettlebillEntryList;
                // 添加空行
                this.settlebillEntryList.push(this.settlebillEntry);
                this.$modal.closeLoading();
            });
        },

        /** 返回至列表页 */
        back(){
            //关闭当前页
            this.$store.dispatch("tagsView/delView", this.$route);
            this.$router.push({path:'/sal/settle/settlebillnolist/'})
        },

        handleOpenInvoice() {
            this.invoiceOpen = true;
            // TODO 获取附件

        },

        deleteEntry(idx){
            this.settlebillEntryList.splice(idx, 1);
            // 行号重新编排
            for(let i=0 ; i<this.settlebillEntryList.length ; i++){
                this.settlebillEntryList[i].lineNo = i+1;
            }
            this.detailForm.rowCount = this.settlebillEntryList.length;
        },

        addEntry(){
            const item = {
                id : null,
                entryId : null,
                settleId : null,
                custId : null,
                siteCode : null,
                siteName : null,
                unit : '',
                qty : 0,
                withoutPrice : 0,
                withoutAmount : 0,
                taxRate : 0,
                tax : 0,
                deductAmount : 0,
                deductRate : 0,
                withoutDiscountAmount : 0,
                discountAmount : 0,
                price : 0,
                amount : 0,
                policyCode : null,
                policyName : null,
                freeTaxType : null,
                freeTaxTypeName : null,
                taxShortName : null,
                productCode : '',
                productName : '',
                specificatCode : null,
                createTime: null
            };
            this.settlebillEntryList.push(item);
        },

        /* ※※ 查询 产品 相关方法 start ※※ */
        /** ① 弹出查询条件-产品 */
        openSearchProductDialogOpen(idx){
            this.currentRowIdx = idx;
            this.searchProductCodeDialogOpen = true;
            // 默认查询
            this.handleSearchProductCodeQuery();
        },
        /** ② 单击行 **/
        handleSearchProductCodeRowClick(row, column, event){
            this.$refs.searchProductCodeSingleTable.toggleRowSelection(row);
        },
        /** ③ 行KEY **/
        getSearchProductCodeListRowKey(row) {
            return row.productCode
        },
        /** ④ 选中产品 **/
        handleSearchProductCodeSelectionChange(selection) {
            if(selection){
                if (selection.length > 1) {
                    const item = selection.pop();
                    this.$refs.searchProductCodeSingleTable.clearSelection();
                    this.$refs.searchProductCodeSingleTable.toggleRowSelection(item);
                    this.searchProductCodes = item.productCode;
                    this.searchProductNames = item.productName;
                    this.searchProduct = item;
                } else {
                    if(selection[0]){
                        this.searchProductCodes = selection[0].productCode;
                        this.searchProductNames = selection[0].productName;
                        this.searchProduct = selection[0];
                    }
                }
            } else {
                this.$refs.table.clearSelection();
                this.searchProductCodes = null;
                this.searchProductNames = null;
                this.searchProduct = {};
            }
        },
        /** ⑤ 点击查询按钮 **/
        handleSearchProductCodeQuery(){
            this.searchProductCodeQueryParams.pageNum = 1;
            this.getSearchProductCodeList();
        },
        /** ⑥ 查询 **/
        getSearchProductCodeList(){
            this.searchProductCodeSelectLoading = true;
            listProduct(this.searchProductCodeQueryParams).then(response => {
                this.searchProductCodeList = response.rows;
                this.searchProductCodeTotal = response.total;
                this.searchProductCodeSelectLoading = false;
            });
        },
        /** ⑦ 点击确认查询 **/
        confirmSearchProductCode() {
            if(this.searchProductCodes){
                this.settlebillEntryList[this.currentRowIdx].productName = this.searchProductNames;
                this.settlebillEntryList[this.currentRowIdx].productCode = this.searchProductCodes;
                this.settlebillEntryList[this.currentRowIdx].taxShortName = this.searchProduct.taxName;
                this.settlebillEntryList[this.currentRowIdx].taxCategoryCode = this.searchProduct.taxCode;
                this.settlebillEntryList[this.currentRowIdx].specificatCode = this.searchProduct.specificatCode;
                this.settlebillEntryList[this.currentRowIdx].unit = this.searchProduct.unit;
                this.settlebillEntryList[this.currentRowIdx].taxRate = this.searchProduct.taxRate;
                this.settlebillEntryList[this.currentRowIdx].isTax = this.searchProduct.isTax;
                // 含税
                if(this.searchProduct.isTax == 1){
                    this.settlebillEntryList[this.currentRowIdx].price = this.searchProduct.price;
                    // 计算不含税单价 单价(不含税) =含税单价 / （1+税率）
                    this.settlebillEntryList[this.currentRowIdx].withoutPrice = Number(this.searchProduct.price / (1 + (this.searchProduct.taxRate/100))).toFixed(8);
                } else {
                    this.settlebillEntryList[this.currentRowIdx].withoutPrice = this.searchProduct.price;
                    // 计算含税单价 单价(含税) =不含税单价* （1+税率）
                    this.settlebillEntryList[this.currentRowIdx].price = Number(this.searchProduct.price * (1 + (this.searchProduct.taxRate/100))).toFixed(8);
                }
            }
            // 关闭查询弹出框
            this.searchProductCodeCancel();
        },
        /** ⑧ 点击关闭查询弹出框 **/
        searchProductCodeCancel() {
            this.searchProductCodeDialogOpen = false;
        },
        /* ※※ 查询 产品 相关方法 end ※※ */



        /* ※※ 查询 税收分类 相关方法 start ※※ */
        /** ① 弹出查询条件-公司代码 */
        openSearchTaxCategoryDialogOpen(idx){
            this.currentRowIdx = idx;
            this.searchTaxCategoryCodeDialogOpen = true;
            // 默认查询
            this.handleSearchTaxCategoryCodeQuery();
        },
        /** ② 单击行 **/
        handleSearchTaxCategoryCodeRowClick(row, column, event){
            this.$refs.searchTaxCategoryCodeSingleTable.toggleRowSelection(row);
        },
        /** ③ 行KEY **/
        getSearchTaxCategoryCodeListRowKey(row) {
            return row.taxCategoryCode
        },
        /** ④ 选中税收分类 **/
        handleSearchTaxCategoryCodeSelectionChange(selection) {
            if(selection){
                if (selection.length > 1) {
                    const item = selection.pop();
                    this.$refs.searchTaxCategoryCodeSingleTable.clearSelection();
                    this.$refs.searchTaxCategoryCodeSingleTable.toggleRowSelection(item);
                    this.searchTaxCategoryCodes = item.taxCategoryCode;
                    this.searchTaxCategoryNames = item.taxShortName;
                } else {
                    if(selection[0]){
                        this.searchTaxCategoryCodes = selection[0].taxCategoryCode;
                        this.searchTaxCategoryNames = selection[0].taxShortName;
                    }
                }
            } else {
                this.$refs.table.clearSelection();
                this.searchTaxCategoryCodes = null;
                this.searchTaxCategoryNames = null;
            }
        },
        /** ⑤ 点击查询按钮 **/
        handleSearchTaxCategoryCodeQuery(){
            this.searchTaxCategoryCodeQueryParams.pageNum = 1;
            this.getSearchTaxCategoryCodeList();
        },
        /** ⑥ 查询 **/
        getSearchTaxCategoryCodeList(){
            this.searchTaxCategoryCodeSelectLoading = true;
            listTaxcategory(this.searchTaxCategoryCodeQueryParams).then(response => {
                this.searchTaxCategoryCodeList = response.rows;
                this.searchTaxCategoryCodeTotal = response.total;
                this.searchTaxCategoryCodeSelectLoading = false;
            });
        },
        /** ⑦ 点击确认查询 **/
        confirmSearchTaxCategoryCode() {
            if(this.searchTaxCategoryCodes){
                this.settlebillEntryList[this.currentRowIdx].taxShortName = this.searchTaxCategoryNames;
                this.settlebillEntryList[this.currentRowIdx].taxCategoryCode = this.searchTaxCategoryCodes;
            }
            // 关闭查询弹出框
            this.searchTaxCategoryCodeCancel();
        },
        /** ⑧ 点击关闭查询弹出框 **/
        searchTaxCategoryCodeCancel() {
            this.searchTaxCategoryCodeDialogOpen = false;
        },
        /* ※※ 查询 公司代码 相关方法 end ※※ */

        // 修改不含税单价
        changeWithoutPrice(idx, row){
            // 计算含税单价 单价(含税) =不含税单价* （1+税率）
            row.price = Number(row.withoutPrice * (1 + (row.taxRate/100))).toFixed(8);
            row.withoutAmount = Number(row.withoutPrice * row.qty).toFixed(8);
            row.amount = Number(row.price * row.qty).toFixed(8);
            row.tax = Number(row.amount - row.withoutAmount).toFixed(8);
            this.refreshSummary();
        },
        // 计算金额
        changePrice(idx, row){
            row.withoutPrice = Number(row.price / (1 + (row.taxRate/100))).toFixed(8);
            row.withoutAmount = Number(row.withoutPrice * row.qty).toFixed(8);
            row.amount = Number(row.price * row.qty).toFixed(8);
            row.tax = Number(row.amount - row.withoutAmount).toFixed(8);
            this.refreshSummary();
        },
        // 切换税率
        changeTax(idx, row){
            this.changeWithoutPrice(idx, row);
            this.changePrice(idx, row);
        },
        // 计算税额
        changeQty(idx, row){
            row.withoutAmount = Number(row.withoutPrice * row.qty).toFixed(8);
            row.amount = Number(row.price * row.qty).toFixed(8);
            row.tax = Number(row.amount - row.withoutAmount).toFixed(8);
            this.refreshSummary();
        },

        /**
         * 修改拆分金额（不含税）
         */
        changeWithoutAmount(idx, row){
            if(row.withoutAmount > this.feeWithoutTax){
                this.$modal.msgError("明细金额(不含税)不能大于待拆金额(不含税)");
                row.withoutAmount = this.feeWithoutTax;
                return;
            }
            // 1. 计算拆分数量 = 拆分金额（不含税）/ 单价（不含税） = withoutAmount/withoutPrice
            row.qty = Number(row.withoutAmount/row.withoutPrice).toFixed(8);
            // 2. 计算拆分金额（不含税） = 拆分金额（含税）* （1+税率） = withoutAmount*(1+taxRate)
            row.amount = Number(row.withoutAmount*((row.taxRate/100)+1)).toFixed(8);
            row.tax = Number(row.amount - row.withoutAmount).toFixed(8);
            // 3. 刷新合计
            this.refreshSummary();
        },
        /**
         * 修改拆分金额（含税）
         */
        changeAmount(idx, row){
            if(row.amount > this.fee){
                this.$modal.msgError("明细金额(含税)不能大于待拆金额(含税)");
                row.amount = this.fee;
                return;
            }
            // 1. 计算拆分数量 = 拆分金额（含税）/ 单价（含税） = amount/price
            row.qty = Number(row.amount/row.price).toFixed(8);
            // 2. 计算拆分金额（不含税） = 拆分金额（含税）/ （1+税率） = amount/(1+taxRate)
            row.withoutAmount = Number(row.amount/((row.taxRate/100)+1)).toFixed(8);
            row.tax = Number(row.amount - row.withoutAmount).toFixed(8);
            // 3. 刷新合计
            this.refreshSummary();
        },

        refreshSummary(){
            let feeWithoutTax = 0;
            let fee = 0;
            let tax = 0;
            this.settlebillEntryList.forEach(item => {
                feeWithoutTax = Number(item.withoutAmount) + feeWithoutTax;
                fee = Number(item.amount) + fee;
                tax = Number(item.tax) + tax;
            });
            this.detailForm.feeWithoutTax = Number(feeWithoutTax).toFixed(2);
            this.detailForm.fee = Number(fee).toFixed(2);
            this.detailForm.tax = Number(tax).toFixed(2);
        },

        /** 提交按钮 */
        submitForm() {
            this.$refs["detailForm"].validate(valid => {
                this.detailForm.tscSettlebillEntryList = this.settlebillEntryList;
                if(this.detailForm.tscSettlebillEntryList.length == 0){
                    this.$modal.msgError("请设置明细行");   valid = false;
                    return;
                }
                this.detailForm.tscSettlebillEntryList.forEach(item => {
                    if(
                        !item.productName || !item.productCode || !item.taxShortName || !item.taxCategoryCode || !item.specificatCode ||
                        !item.unit || !item.qty || !item.withoutPrice || !item.withoutAmount || !item.price ||
                        !item.amount || !item.taxRate
                    ) {
                        this.$modal.msgError("请完整设置明细行");  valid = false;
                        return;
                    }
                    if(
                        item.qty === 0
                    ) {
                        this.$modal.msgError("请设置明细行数量");  valid = false;
                        return;
                    }
                });
                if (valid) {
                    updateSettlebill(this.detailForm).then(response => {
                        this.$modal.msgSuccess("修改成功");
                        //关闭当前页
                        this.$store.dispatch("tagsView/delView", this.$route);
                        //
                        this.$router.push({path: '/sal/settle/settlebillnolist/'});
                    });
                }
            });
        },
    }
}
</script>
